<!DOCTYPE html>
<html>
<head>
    <title>大盒子</title>
    <style>
        html, body, .box {
            height: 100%;
            margin: 0;
        }
        .box {
            display: flex;
            flex-wrap: wrap;
            align-content: flex-start;
            padding: 2%;
        }
        .small-box {
            flex: 0 0 calc(25% - 4%); /* 4% = 2% padding * 2 sides */
            padding-bottom: calc(25% - 4%);
            background-color: #f2f2f2;
            border: 1px solid #ddd;
            margin: 2%;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="small-box"></div>
        <div class="small-box"></div>
        <div class="small-box"></div>
        <div class="small-box"></div>
        <div class="small-box"></div>
        <div class="small-box"></div>
        <div class="small-box"></div>
        <div class="small-box"></div>
    </div>
</body>
</html>